#! /usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall
include /usr/share/dpkg/buildflags.mk

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
 
INSTALLDIR := $(CURDIR)/debian/tmp
datadir=/usr/share/squid3

DEB_DH_INSTALL_SOURCEDIR := $(INSTALLDIR)
DEB_INSTALL_DOCS_squid3-common := CONTRIBUTORS CREDITS QUICKSTART RELEASENOTES.html \
						SPONSORS 

DEB_CONFIGURE_EXTRA_FLAGS := --datadir=/usr/share/squid3 \
		--sysconfdir=/etc/squid3 \
		--mandir=/usr/share/man \
		--enable-inline \
		--enable-ssl \
		--enable-ssl-crtd \ 	
		--disable-arch-native \
		--enable-async-io=8 \
		--enable-storeio="ufs,aufs,diskd,rock" \
		--enable-removal-policies="lru,heap" \
		--enable-delay-pools \
		--enable-cache-digests \
		--enable-icap-client \
		--enable-follow-x-forwarded-for \
		--disable-auth \ 	
		--disable-auth-basic \ 	
		--disable-auth-digest \
		--disable-auth-negotiate \ 	
		--disable-auth-ntlm \
		--enable-storeid-rewrite-helpers \ 	
		--enable-build-info="Build by raja_malam72" \
		--enable-eui \
		--enable-esi \
		--enable-icmp \
		--enable-snmp \
		--enable-zph-qos \
		--disable-ipv6 \
		--disable-translation \
		--with-openssl \
		--with-included-ltdl \
		--with-swapdir=/var/spool/squid3 \
		--with-logdir=/var/log/squid3 \
		--with-pidfile=/var/run/squid3.pid \
		--with-filedescriptors=65536 \
		--with-large-files \
		--with-default-user=proxy

DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)

ifeq ($(DEB_HOST_ARCH_OS), kfreebsd)
		DEB_CONFIGURE_EXTRA_FLAGS += --enable-kqueue
endif
ifeq ($(DEB_HOST_ARCH_OS), linux)
		DEB_CONFIGURE_EXTRA_FLAGS += --enable-linux-netfilter
endif

DEB_MAKE_CLEAN_TARGET = distclean

DEB_FIXPERMS_EXCLUDE = /usr/lib/squid3/pinger

install/squid3::
	install -m 755 -g root -d $(INSTALLDIR)/usr/lib/cgi-bin
	mv $(INSTALLDIR)/etc/squid3/squid.conf.documented $(INSTALLDIR)/etc/squid3/squid.conf
	mv $(INSTALLDIR)/usr/lib/squid3/cachemgr.cgi $(INSTALLDIR)/usr/lib/cgi-bin/cachemgr.cgi
	mv $(INSTALLDIR)/usr/sbin/squid $(INSTALLDIR)/usr/sbin/squid3
	mv $(INSTALLDIR)/usr/share/man/man8/squid.8 $(INSTALLDIR)/usr/share/man/man8/squid3.8
	install -m 755 -g root -d $(INSTALLDIR)/etc/init.d
	install -m 755 -g root -d $(INSTALLDIR)/etc/logrotate.d
	install -m 755 -g root -d $(INSTALLDIR)/etc/resolvconf
	install -m 755 -g root -d $(INSTALLDIR)/etc/resolvconf/update-libc.d
	install -m 755 -g root -d $(INSTALLDIR)/etc/ufw/applications.d
	install -m 755 -g root debian/squid3.rc $(INSTALLDIR)/etc/init.d/squid3
	install -m 755 -g root debian/squid3.resolvconf $(INSTALLDIR)/etc/resolvconf/update-libc.d/squid3
	install -m 644 -g root debian/squid3.logrotate $(INSTALLDIR)/etc/logrotate.d/squid3
	install -m 644 -g root debian/squid3.ufw.profile $(INSTALLDIR)/etc/ufw/applications.d/squid3
	install -m 755 -g root -d debian/squid3/var/log
	install -m 755 -g root -d debian/squid3/var/spool
	install -m 755 -g root -d debian/squid3/var/run
	install -m 750 -o proxy -g proxy -d debian/squid3/var/log/squid3
	install -m 750 -o proxy -g proxy -d debian/squid3/var/spool/squid3
	install -m 755 -g root -d $(INSTALLDIR)/usr/share/man/man1
	mv $(INSTALLDIR)/usr/bin/purge $(INSTALLDIR)/usr/bin/squid-purge
	install -m 644 -g root debian/squid-purge.8  $(INSTALLDIR)/usr/share/man/man8
	chmod 4755 $(INSTALLDIR)/usr/lib/squid3/pinger

clean::
	# nothing to do
